<template>
  <div class="product">
    <div class="title">
      <h3>{{ title }}</h3>
      <span v-if="title==='推荐期刊'" style="margin-top: 20px;cursor: pointer;" @click="toMore">查看更多></span>
    </div>
    <div class="container">
      <div v-if="bookData.length===0">
        暂时没有数据
      </div>
      <div class="d2">
        <div v-for="item2 in bookData" @click="toDetail(item2.id)">
          <img class="imgs" :src="item2.coverAddress" alt="">
          <p class="p1">{{ item2.name }}</p>
          <span class="p3">￥{{ item2.price }}</span>
          <span class="p4">￥{{ item2.price * 1.2 | myFilter }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "bookList",
  props: ["bookData", 'title'],
  filters: {
    myFilter(value) {
      return parseFloat(value).toFixed(2);
    }
  },
  methods: {
    toDetail(id) {
      this.$router.push({
        path: '/detail',
        query: {
          id
        }
      });
    },
    toMore() {
      this.$router.push('/more');
    }
  }
}
</script>
